﻿using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MDK.Winform
{
    public partial class frmUpdateMsg : XtraForm
    {
        public enum MessageBoxStyle
        {
            info = 0,
            question = 1,
            error = 2,
            success = 3
        };

        public frmUpdateMsg()
        {
            InitializeComponent();
        }
 
        public frmUpdateMsg(string title,string message, MessageBoxStyle messageBoxStyle)
        {
            InitializeComponent();

            //询问窗口，两个按钮
            if (messageBoxStyle == MessageBoxStyle.question)
            {
                lbtitle.Text = title;
                btn_ok.Text = "确定";
                btn_cancel.Text = "取消";
            }
            this.labelinfo.Text = message;
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void btn_ok_only_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        private void picclose_Click(object sender, EventArgs e)
        {
            this.Close();
        }


        #region 无边框移动
        //定义无边框窗体Form  
        [DllImport("user32.dll")]//*********************拖动无窗体的控件  
        public static extern bool ReleaseCapture();
        [DllImport("user32.dll")]
        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
        public const int WM_SYSCOMMAND = 0x0112;
        public const int SC_MOVE = 0xF010;
        public const int HTCAPTION = 0x0002;

        private void tableLayoutPanel_top_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);//*********************调用移动无窗体控件函数  
        }
        private void lbtitle_MouseDown(object sender, MouseEventArgs e)
        {
            ReleaseCapture();
            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);//*********************调用移动无窗体控件函数  
        }

        private void frmFastMessageBox_Paint(object sender, PaintEventArgs e)
        {
            Rectangle myRectangle = new Rectangle(0, 0, this.Width, this.Height);
            ControlPaint.DrawBorder(e.Graphics, myRectangle,
                    Color.Gray, 1, ButtonBorderStyle.Solid,
                    Color.Gray, 1, ButtonBorderStyle.Solid,
                    Color.Gray, 1, ButtonBorderStyle.Solid,
                    Color.Gray, 1, ButtonBorderStyle.Solid);
        }




        #endregion

        #region 官网链接
        private void labweb_Click(object sender, EventArgs e)
        {
            Process.Start("www.MDK.Winform.cn");
        }
        #endregion
    }
}
